home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo4.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  6.5 KB  |  179 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include "Symbols.h"
  10.  
  11. /***********************************************************************/
  12.  
  13. long __stack = 8192;
  14. struct Library *MUIMasterBase;
  15.  
  16. /***********************************************************************/
  17.  
  18. #ifndef MAKE_ID
  19. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  20. #endif
  21.  
  22. /***********************************************************************/
  23.  
  24. struct MUIS_TheBar_Brush cbrush =
  25. {
  26.     Symbols_Data,
  27.     SYMBOLS_WIDTH,
  28.     SYMBOLS_HEIGHT,
  29.     SYMBOLS_TOTALWIDTH,
  30.     0,
  31.     0,
  32.     SYMBOLS_WIDTH,
  33.     SYMBOLS_HEIGHT,
  34.     Symbols_Colors,
  35.     SYMBOLS_NUMCOLORS,
  36.     SYMBOLS_TRCOLOR,
  37.     SYMBOLS_CSIZE,
  38.     SYMBOLS_FLAGS
  39. };
  40.  
  41. struct MUIS_TheBar_Brush *brushes[] = {&cbrush,NULL};
  42.  
  43. struct MUIS_TheBar_Button buttons[] =
  44. {
  45.     {7,  0, "_Face",  "Just a face."     },
  46.     {14, 1, "_Mouse", "Your mouse."      },
  47.     {17, 2, "_Tree",  "Mind takes place."},
  48.     {MUIV_TheBar_BarSpacer, -1},
  49.     {26, 3, "_Help",  "Read this!."      },
  50.     {34, 4, "_ARexx", "ARexx for ever!." },
  51.     {1,  5, "_Host",  "Your computer."   },
  52.     {MUIV_TheBar_End},
  53. };
  54.  
  55. /***********************************************************************/
  56.  
  57. char *appareances[] = {"Images and text","Images","Text",NULL};
  58. char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
  59.  
  60. int
  61. main(int argc,char **argv)
  62. {
  63.     int res;
  64.  
  65.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  66.     {
  67.         Object *app, *win, *sb, *appareance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
  68.  
  69.         if (app = ApplicationObject,
  70.                 MUIA_Application_Title,         "TheBar Demo6",
  71.                 MUIA_Application_Version,       "$VER: TheBarDemo6 1.0 (24.6.2003)",
  72.                 MUIA_Application_Copyright,     "Copyright 2003 by Alfonso Ranieri",
  73.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  74.                 MUIA_Application_Description,  "TheBar example",
  75.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  76.  
  77.                 SubWindow, win = WindowObject,
  78.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  79.                     MUIA_Window_Title,          "TheBar Demo6",
  80.                     WindowContents, VGroup,
  81.                         Child, sb = TheBarObject,
  82.                             GroupFrame,
  83.                             MUIA_Group_Horiz,            TRUE,
  84.                             MUIA_TheBar_EnableKeys,      TRUE,
  85.                             MUIA_TheBar_Buttons,         buttons,
  86.                             MUIA_TheBar_StripBrush,      &cbrush,
  87.                             MUIA_TheBar_StripCols,       16,
  88.                             MUIA_TheBar_StripRows,       3,
  89.                             MUIA_TheBar_StripHorizSpace, 0,
  90.                             MUIA_TheBar_StripVertSpace,  0,
  91.                         End,
  92.                         Child, VGroup,
  93.                             GroupFrameT("Settings"),
  94.                             Child, HGroup,
  95.                                 Child, Label2("Appareance"),
  96.                                 Child, appareance = MUI_MakeObject(MUIO_Cycle,NULL,appareances),
  97.                                 Child, Label2("Label pos"),
  98.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  99.                             End,
  100.                             Child, HGroup,
  101.                                 Child, HSpace(0),
  102.                                 Child, Label1("Borderless"),
  103.                                 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  104.                                 Child, HSpace(0),
  105.                                 Child, Label1("Sunny"),
  106.                                 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  107.                                 Child, HSpace(0),
  108.                                 Child, Label1("Raised"),
  109.                                 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  110.                                 Child, HSpace(0),
  111.                                 Child, Label1("Scaled"),
  112.                                 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  113.                                 Child, HSpace(0),
  114.                             End,
  115.                         End,
  116.                         Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  117.                     End,
  118.                 End,
  119.             End)
  120.         {
  121.             ULONG sigs = 0, id;
  122.  
  123.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  124.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  125.  
  126.             set(win,MUIA_Window_Open,TRUE);
  127.  
  128.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  129.             {
  130.                 if (id==TAG_USER)
  131.                 {
  132.                     ULONG appareanceV, labelPosV, borderlessV, sunnyV, raisedV, scaledV;
  133.  
  134.                     get(appareance,MUIA_Cycle_Active,&appareanceV);
  135.                     get(labelPos,MUIA_Cycle_Active,&labelPosV);
  136.                     get(borderless,MUIA_Selected,&borderlessV);
  137.                     get(sunny,MUIA_Selected,&sunnyV);
  138.                     get(raised,MUIA_Selected,&raisedV);
  139.                     get(scaled,MUIA_Selected,&scaledV);
  140.  
  141.                     SetAttrs(sb,MUIA_TheBar_ViewMode,   appareanceV,
  142.                                 MUIA_TheBar_LabelPos,   labelPosV,
  143.                                 MUIA_TheBar_Borderless, borderlessV,
  144.                                 MUIA_TheBar_Sunny,      sunnyV,
  145.                                 MUIA_TheBar_Raised,     raisedV,
  146.                                 MUIA_TheBar_Scaled,     scaledV,
  147.                                 TAG_DONE);
  148.                 }
  149.  
  150.                 if (sigs)
  151.                 {
  152.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  153.                     if (sigs & SIGBREAKF_CTRL_C) break;
  154.                 }
  155.             }
  156.  
  157.             MUI_DisposeObject(app);
  158.  
  159.             res = RETURN_OK;
  160.         }
  161.         else
  162.         {
  163.             printf("%s: can't create application\n",argv[0]);
  164.             res = RETURN_FAIL;
  165.         }
  166.  
  167.         CloseLibrary(MUIMasterBase);
  168.     }
  169.     else
  170.     {
  171.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  172.         res = RETURN_ERROR;
  173.     }
  174.  
  175.     return res;
  176. }
  177.  
  178. /***********************************************************************/
  179.